home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.002 / stk-3 / STk-3.1 / Tk / xlib / xutil.c < prev   
Encoding:
C/C++ Source or Header  |  1996-01-31  |  4.6 KB  |  210 lines

  1. /* 
  2.  * xutil.c --
  3.  *
  4.  *    This function contains generic X emulation routines.
  5.  *
  6.  * Copyright (c) 1995 Sun Microsystems, Inc.
  7.  *
  8.  * See the file "license.terms" for information on usage and redistribution
  9.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  10.  */
  11.  
  12. static char sccsid[] = "@(#) xutil.c 1.7 95/08/14 18:32:54";
  13.  
  14. #include "tk.h"
  15. #ifdef MAC_TCL
  16. #       include <Xutil.h>
  17. #       include <Xatom.h>
  18. #else
  19. #       include <X11/Xutil.h>
  20. #       include <X11/Xatom.h>
  21. #endif
  22.  
  23. /*
  24.  *----------------------------------------------------------------------
  25.  *
  26.  * XInternAtom --
  27.  *
  28.  *    This procedure simulates the XInternAtom function by calling
  29.  *    Tk_Uid to get a unique id for every atom.  This is only a
  30.  *    partial implementation, since it doesn't work across
  31.  *    applications.
  32.  *
  33.  * Results:
  34.  *    A new Atom.
  35.  *
  36.  * Side effects:
  37.  *    None.
  38.  *
  39.  *----------------------------------------------------------------------
  40.  */
  41.  
  42. Atom
  43. XInternAtom(display, atom_name, only_if_exists)
  44.     Display* display;
  45.     _Xconst char* atom_name;
  46.     Bool only_if_exists;
  47. {
  48.     static Atom atom = XA_LAST_PREDEFINED;
  49.     
  50.     display->request++;
  51.     return ++atom;
  52. }
  53.  
  54. /*
  55.  *----------------------------------------------------------------------
  56.  *
  57.  * XGetVisualInfo --
  58.  *
  59.  *    Returns information about the specified visual.
  60.  *
  61.  * Results:
  62.  *    Returns a newly allocated XVisualInfo structure.
  63.  *
  64.  * Side effects:
  65.  *    Allocates storage.
  66.  *
  67.  *----------------------------------------------------------------------
  68.  */
  69.  
  70. XVisualInfo *
  71. XGetVisualInfo(display, vinfo_mask, vinfo_template, nitems_return)
  72.     Display* display;
  73.     long vinfo_mask;
  74.     XVisualInfo* vinfo_template;
  75.     int* nitems_return;
  76. {
  77.     XVisualInfo *info = (XVisualInfo *)ckalloc(sizeof(XVisualInfo));
  78.     info->visual = DefaultVisual(display, 0);
  79.     info->visualid = info->visual->visualid;
  80.     info->screen = 0;
  81.     info->depth = info->visual->bits_per_rgb;
  82.     info->class = info->visual->class;
  83.     info->colormap_size = info->visual->map_entries;
  84.     info->bits_per_rgb = info->visual->bits_per_rgb;
  85.     info->red_mask = info->visual->red_mask;
  86.     info->green_mask = info->visual->green_mask;
  87.     info->blue_mask = info->visual->blue_mask;
  88.     
  89.     if (((vinfo_mask & VisualIDMask)
  90.         && (vinfo_template->visualid != info->visualid))
  91.         || ((vinfo_mask & VisualScreenMask)
  92.             && (vinfo_template->screen != info->screen))
  93.         || ((vinfo_mask & VisualDepthMask)
  94.             && (vinfo_template->depth != info->depth))
  95.         || ((vinfo_mask & VisualClassMask)
  96.             && (vinfo_template->class != info->class))
  97.         || ((vinfo_mask & VisualColormapSizeMask)
  98.             && (vinfo_template->colormap_size != info->colormap_size))
  99.         || ((vinfo_mask & VisualBitsPerRGBMask)
  100.             && (vinfo_template->bits_per_rgb != info->bits_per_rgb))
  101.         || ((vinfo_mask & VisualRedMaskMask)
  102.             && (vinfo_template->red_mask != info->red_mask))
  103.         || ((vinfo_mask & VisualGreenMaskMask)
  104.             && (vinfo_template->green_mask != info->green_mask))
  105.         || ((vinfo_mask & VisualBlueMaskMask)
  106.             && (vinfo_template->blue_mask != info->blue_mask))
  107.     ) {
  108.     ckfree((char *) info);
  109.     return NULL;
  110.     }
  111.  
  112.     *nitems_return = 1;
  113.     return info;
  114. }
  115.  
  116. /*
  117.  *----------------------------------------------------------------------
  118.  *
  119.  * XVisualIDFromVisual --
  120.  *
  121.  *    Retrieves the visual ID for the specified visual type.
  122.  *
  123.  * Results:
  124.  *    Returns a visual ID.
  125.  *
  126.  * Side effects:
  127.  *    None.
  128.  *
  129.  *----------------------------------------------------------------------
  130.  */
  131.  
  132. VisualID
  133. XVisualIDFromVisual(visual)
  134.     Visual* visual;
  135. {
  136.     return visual->visualid;
  137. }
  138.  
  139. /*
  140.  *----------------------------------------------------------------------
  141.  *
  142.  * XFree --
  143.  *
  144.  *    Release memory allocated by X emulation routines.
  145.  *
  146.  * Results:
  147.  *    None.
  148.  *
  149.  * Side effects:
  150.  *    Frees the passed in memory.
  151.  *
  152.  *----------------------------------------------------------------------
  153.  */
  154.  
  155. void
  156. XFree(data)
  157.     void* data;
  158. {
  159.     if (data != NULL) {
  160.     ckfree((char *) data);
  161.     }
  162. }
  163.  
  164. /*
  165.  *----------------------------------------------------------------------
  166.  *
  167.  * XNoOp --
  168.  *
  169.  *    Null request.
  170.  *
  171.  * Results:
  172.  *    None.
  173.  *
  174.  * Side effects:
  175.  *    Increments the request counter.
  176.  *
  177.  *----------------------------------------------------------------------
  178.  */
  179.  
  180. void
  181. XNoOp(display)
  182.     Display* display;
  183. {
  184.     display->request++;
  185. }
  186.  
  187. /*
  188.  *----------------------------------------------------------------------
  189.  *
  190.  * XSync --
  191.  *
  192.  *    Synchronize X server.  This is a noop under Windows.
  193.  *
  194.  * Results:
  195.  *    None.
  196.  *
  197.  * Side effects:
  198.  *    Increments the request counter.
  199.  *
  200.  *----------------------------------------------------------------------
  201.  */
  202.  
  203. void
  204. XSync(display, discard)
  205.     Display* display;
  206.     Bool discard;
  207. {
  208.     display->request++;
  209. }
  210.